using System;
using System.Diagnostics;
using System.Runtime.CompilerServices;

namespace DanMuHelper.Logging
{
    /// <summary>
    /// <para>使用Conditional实现编译器级别优化</para>
    /// <para>自动打印方法名和类文件名</para>
    /// <para>日志接口，自动添加TAG标记，便于在LogConsole过滤日志</para>
    /// <para>Editor模式下，可以使用富文本高亮log</para>
    /// <para>Unicode编码： \u279c （向右的一个箭头）</para>
    /// <para>日志等级扩展：添加一个Debug等级</para>
    /// <para>移动端默认只显示Warning, Error, Exception级别日志</para>
    /// <para>移动端移动端打印时间</para>
    /// </summary>
    public static partial class Echo
    {
        public static class Format
        {
            public static void Info(string format, params object[] args)
            {
                Write(EchoType.Info, string.Format(format, args));
            }

            public static void InfoInContext(UnityEngine.Object context, string format, params object[] args)
            {
                WriteInContext(EchoType.Info, context, string.Format(format, args));
            }

            public static void Warning(string format, params object[] args)
            {
                Write(EchoType.Warning, string.Format(format, args));
            }

            public static void WarningInContext(UnityEngine.Object context, string format, params object[] args)
            {
                WriteInContext(EchoType.Warning, context, string.Format(format, args));
            }

            public static void Error(string format, params object[] args)
            {
                Write(EchoType.Error, string.Format(format, args));
            }

            public static void ErrorInContext(UnityEngine.Object context, string format, params object[] args)
            {
                WriteInContext(EchoType.Error, context, string.Format(format, args));
            }
        }

        [Conditional("UNITY_EDITOR"), Conditional("DLLOG_I"), Conditional("DEVELOPMENT_BUILD")]
        public static void Info(object message, [CallerFilePath] string callerFilePath = "", [CallerMemberName] string callerMemberName = "")
        {
            Write(EchoType.Info, message, callerFilePath, callerMemberName);
        }

        [Conditional("UNITY_EDITOR"), Conditional("DLLOG_I"), Conditional("DEVELOPMENT_BUILD")]
        public static void InfoInContext(UnityEngine.Object context, object message, [CallerFilePath] string callerFilePath = "", [CallerMemberName] string callerMemberName = "")
        {
            WriteInContext(EchoType.Info, context, message, callerFilePath, callerMemberName);
        }

        public static void Warning(object message, [CallerFilePath] string callerFilePath = "", [CallerMemberName] string callerMemberName = "")
        {
            Write(EchoType.Warning, message, callerFilePath, callerMemberName);
        }

        public static void WarningInContext(UnityEngine.Object context, object message, [CallerFilePath] string callerFilePath = "", [CallerMemberName] string callerMemberName = "")
        {
            WriteInContext(EchoType.Warning, context, message, callerFilePath, callerMemberName);
        }

        public static void Error(object message, [CallerFilePath] string callerFilePath = "", [CallerMemberName] string callerMemberName = "")
        {
            Write(EchoType.Error, message, callerFilePath, callerMemberName);
        }

        public static void ErrorInContext(UnityEngine.Object context, object message, [CallerFilePath] string callerFilePath = "", [CallerMemberName] string callerMemberName = "")
        {
            WriteInContext(EchoType.Error, context, message, callerFilePath, callerMemberName);
        }

        public static void Exception(Exception exception, [CallerFilePath] string callerFilePath = "", [CallerMemberName] string callerMemberName = "")
        {
            Write(EchoType.Error, exception, callerFilePath, callerMemberName);
        }

        public static void ExceptionInContext(UnityEngine.Object context, Exception exception, [CallerFilePath] string callerFilePath = "", [CallerMemberName] string callerMemberName = "")
        {
            WriteInContext(EchoType.Error, context, exception, callerFilePath, callerMemberName);
        }

    }

}
